package com.example.cunion.controller;

import com.example.cunion.common.R;
import com.example.cunion.controller.form.PageFom;
import com.example.cunion.entity.PostActClass;
import com.example.cunion.service.PostActClassService;
import com.example.cunion.service.PostActClassService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/postActClass")
public class PostActClassController {

    @Resource
    private PostActClassService postActClassService;
    
    @PostMapping("/addPostActClassByMp")
    public R addPostActClassByMp(@RequestHeader("token") String token, @RequestBody PostActClass postActClass) {
        postActClassService.addPostActClassByMp(postActClass);
        return R.ok();
    }

    @GetMapping("/deletePostActClassByMp")
    public R deletePostActClassByMp(@RequestHeader("token") String token, @RequestParam("postActClassId") String postActClassId) {
        postActClassService.deletedPostActClassByMp(postActClassId);
        return R.ok();
    }
    @PostMapping("/updatePostActClassByMp")
    public R updatePostActClassByMp(@RequestHeader("token") String token, @RequestBody PostActClass postActClass) {
        postActClassService.updatePostActClassByMp(postActClass);
        return R.ok();
    }
    @PostMapping("/searchPostActClassByMp")
    public R searchPostActClassByMp(@RequestHeader("token") String token, @RequestBody PageFom form){
        List<PostActClass> list = postActClassService.searchPostActClassByMp(form.getStart(), form.getLength());
        return R.ok().put("result", list);
    }
}
